home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6226 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.une.edu.au!usenet
  2. From: Jon Snow <jwilkie@turing.une.edu.au>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How to delete array of pointers?
  5. Date: 11 Feb 1996 22:53:32 GMT
  6. Organization: University of New England
  7. Message-ID: <4fls1c$1n1@grivel.une.edu.au>
  8. References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk>
  9. NNTP-Posting-Host: turing.une.edu.au
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (X11; I; OSF1 V2.0 alpha)
  14. X-URL: news:4fgvsu$5q4@eng_ser1.erg.cuhk.hk
  15.  
  16. ywleung@cs.cuhk.hk (Marty McFly) wrote:
  17. >If I write the following code in a function:
  18. >
  19. >    int** ptr;
  20. >    ptr = new int*[1000];
  21. >
  22. >Is this code means allocating 1000 integer pointers which is pointed by ptr?
  23. >And then somehow I assign integer variable to ptr[0], ptr[1], ... and so on.
  24. >So at the end of the function, how can I reclaim just those pointers?  The key
  25. >point is that those integer variable assigned to the pointers should not be 
  26. >deleted.
  27. >
  28. >Regards,
  29. >Marty McFly.
  30.  
  31. I assume since you don't want to delete the pointers assigned a value that
  32. you wish to free up only the memory in the unused pointers. Try using the 
  33. C functions calloc and realloc. If you don't like using C then create your
  34. own C++ memory class.
  35. Hope this is what your after.
  36. Regards Jon.
  37.  
  38. Jon Snow <jwilkie@turing.une.edu.au>
  39.  
  40.